package com.example.demo.arithmetic.datastructure.tree;

/**
 * 二叉树反转
 */
public class Leetcode226 {


    public TreeNode reverse(TreeNode node) {
        reverseFn(node);
        return node;
    }

    public void reverseFn(TreeNode node) {
        if (node == null) {
            return;
        }
        TreeNode t = node.left;
        node.left = node.right;
        node.right = t;
        reverseFn(node.right);
        reverseFn(node.left);

    }
}
